package com.lb.jwitter.action;


 import java.util.ArrayList;
 import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import java.util.Collection;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import com.opensymphony.xwork2.Action; 
 import com.lb.jwitter.service.ConditionReport; 
 import com.lb.jwitter.service.TblThongTinHocVien;
 import com.lb.jwitter.service.TblThongTinHocVienService;
 import com.lb.jwitter.service.TblCTDTChuyenNganh;
 import com.lb.jwitter.service.TblCTDTChuyenNganhService;

import com.lb.jwitter.service.TblCTDTKhoa;
 import com.lb.jwitter.service.TblCTDTKhoaService;

import com.lb.jwitter.service.TblCTDTHeDaoTao;
 import com.lb.jwitter.service.TblCTDTHeDaoTaoService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblThongTinHocVienFormAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    public void setPageSize(int pageSize) { this.pageSize = pageSize; }

    private int page; 
    public int getPage() { return page; }

    public void setPage(int page) { this.page = page; }

    private int pages; 
    public int getPages() { return pages; }

    public void setPages(int pages) { this.pages = pages; }

    private String dataString; 
    public String getDataString() { return dataString; }

    private Collection<TblThongTinHocVien> tblThongTinHocViens; 
    public Collection<TblThongTinHocVien>  getTblThongTinHocViens() {
         return tblThongTinHocViens; 
      } 

    private TblThongTinHocVienService tblThongTinHocVienService; 

    private Collection<TblCTDTChuyenNganh> tblCTDTChuyenNganhs; 
    public Collection<TblCTDTChuyenNganh>  getTblCTDTChuyenNganhs(){ 
              return tblCTDTChuyenNganhs; 
     } 

    private TblCTDTChuyenNganhService tblCTDTChuyenNganhService; 

    private Collection<TblCTDTKhoa> tblCTDTKhoas; 
    public Collection<TblCTDTKhoa>  getTblCTDTKhoas(){ 
              return tblCTDTKhoas; 
     } 

    private TblCTDTKhoaService tblCTDTKhoaService; 

    private Collection<TblCTDTHeDaoTao> tblCTDTHeDaoTaos; 
    public Collection<TblCTDTHeDaoTao>  getTblCTDTHeDaoTaos(){ 
              return tblCTDTHeDaoTaos; 
     } 

    private TblCTDTHeDaoTaoService tblCTDTHeDaoTaoService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
    { 
        try{ 
      Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_ThongTin_HocVien", "xem")){ 
        return "noprivilege"; 
    }
tblThongTinHocVienService = (TblThongTinHocVienService) context.getBean("tbl_ThongTin_HocVienClient"); 
         tblCTDTChuyenNganhService = (TblCTDTChuyenNganhService) context.getBean("tbl_CTDT_ChuyenNganhClient"); 

        tblCTDTKhoaService = (TblCTDTKhoaService) context.getBean("tbl_CTDT_KhoaClient"); 

        tblCTDTHeDaoTaoService = (TblCTDTHeDaoTaoService) context.getBean("tbl_CTDT_HeDaoTaoClient"); 

       if(pageSize == 0){ 
            pageSize = 20; 
        } 
        if(page == 0){ 
            page =1; 
        } 
//        tblThongTinHocViens =        tblThongTinHocVienService.findAlltblThongTinHocVien(pageSize, page); 
//        pages = tblThongTinHocVienService.counttblThongTinHocVienByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      tblCTDTChuyenNganhs = tblCTDTChuyenNganhService.findAlltblCTDTChuyenNganh(0, 0);
      tblCTDTKhoas = tblCTDTKhoaService.findAlltblCTDTKhoa(0, 0);
      tblCTDTHeDaoTaos = tblCTDTHeDaoTaoService.findAlltblCTDTHeDaoTao(0, 0);
      dataString = ""; 
      dataString += "&mSSV="; 
      dataString += "&hoTen="; 
      dataString += "&chuyenNganhId=" ; 
      dataString += "&tukhoaHoc="; 
      dataString += "&denkhoaHoc="; 
      dataString += "&khoaId=" ; 
      dataString += "&heDaoTaoId=" ; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi Form tbl_ThongTin_HocVien Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
